import java.util.Iterator;
import java.util.List;

public class Main {

    static int cnt;
    public static void output() {
        Iterator<String> it = First.first.keySet().iterator();
        cnt = 1;
        System.out.println("first集:");
        while (it.hasNext()) {
            Object key = it.next();
            Object value = First.first.get(key);
            System.out.println(cnt++ + " " + key + " " + value);
        }
        System.out.println();

        cnt = 1;
        System.out.println("V_N集:");
        for (String str : Init.V_N) {
            System.out.println(cnt++ + " " + str);
        }
        System.out.println();

        cnt = 1;
        System.out.println("V_T集:");
        for (String str : Init.V_T) {
            System.out.println(cnt++ + " " + str);
        }
        System.out.println();

        Iterator<String> it2 = Init.Production.keySet().iterator();
        cnt = 1;
        System.out.println("Production集:");
        while (it2.hasNext()) {
            Object key = it2.next();
            Object value = Init.Production.get(key);
            System.out.println(cnt++ + " " + key + " " + value);
        }
        System.out.println();

        Iterator<List<String>> it3 = Follow.firstX.keySet().iterator();
        cnt = 1;
        System.out.println("firstX集:");
        while (it3.hasNext()) {
            Object key = it3.next();
            Object value = Follow.firstX.get(key);
            System.out.println(cnt++ + " " + key + " " + value);
        }
        System.out.println();

        Iterator<String> it4 = Follow.follow.keySet().iterator();
        cnt = 1;
        System.out.println("follow集:");
        while (it4.hasNext()) {
            Object key = it4.next();
            Object value = Follow.follow.get(key);
            System.out.println(cnt++ + " " + key + " " + value);
        }
        System.out.println();
    }

    public static void main(String[] args) {
        First f = new First(Init.getInstance("1wenfa.txt"));
        f.constructFirst();
        f.constructFollow();
        output();
    }
}